/*****************************************************************
 Naicigam Engine v0.1

 File: VertexBuffer.h
 Created: 01/03/08
*****************************************************************/

//----------------------------------------------------------------
#ifndef VERTEX_BUFFER_H
#define VERTEX_BUFFER_H
//----------------------------------------------------------------
#include <windows.h>
#include <d3d9.h>
#include <assert.h>
//----------------------------------------------------------------
namespace myd
{
//----------------------------------------------------------------
template<class VertexFormat, unsigned int FVF>
//----------------------------------------------------------------
class VertexBuffer
{
public:

	VertexBuffer ();
	~VertexBuffer ();
	
	// create the vertex buffer
	bool create (IDirect3DDevice9* pkDev, bool bDynamic);

	// release the vertex buffer
	void release ();

	// draw the content
	void draw (const VertexFormat* pkVertices, 
				D3DPRIMITIVETYPE ePrimitive, 
				unsigned int uiVertexCount);

	// force send content to video card
	void flush ();

	// set as current VB
	void bind () const;

private:
	unsigned int m_uiVBOSize;
	unsigned int m_uiFlush;
	unsigned int m_uiBase;
	unsigned int m_uiVertexToLock;

	D3DPRIMITIVETYPE m_ePrimitiveType;
	IDirect3DVertexBuffer9* m_pkVBO;
	IDirect3DDevice9* m_pkDev;
};
//----------------------------------------------------------------
#include "myd_vertexbuffer.inl"
//----------------------------------------------------------------
} // end namespace
//----------------------------------------------------------------
#endif // _VS_VERTEX_BUFFER_H_
//----------------------------------------------------------------